<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>虚拟滚动</title>
    <style>
        .container{
            display: flex;
            flex-direction: column;
            justify-content: center;
            align-items: center;
        }
        .box{
            width: 400px;
            height: 300px;
            border: 1px solid gainsboro;
            box-sizing: border-box;
            overflow: hidden;
            position: relative;
        }
        .item{
            width: 100%;
            height: 40px;
            box-sizing: border-box;
            border-bottom: 1px solid #eee;
        }
        .vs_scroll {
            position: absolute;
            top: 0;
            right: 0;
            width: 20px;
            height: 100%;
            background-color: #f3f3f3;
            z-index: 2;
        }
        .vs_scroll-bar {
            width: 100%;
            min-height: 40px;
            background-color: #b243c5;
            cursor: pointer;
        }
    </style>
</head>
<body>
<div class="container">
    <h1>虚拟滚动Demo</h1>
    <div class="box">

    </div>
</div>

<script type="module">
    import VirtualScroll from './Scroller.js';


    let $el = document.querySelector(".box");

    let data = []
    for (let i = 0; i < 100; i++) {
      data.push(i)
    }
    window.Scroller = new VirtualScroll($el, data, (item) => {
      const $item = document.createElement("div")
      $item.classList.add("item")
      $item.innerHTML = item.original

      return $item
    });
</script>
</body>
</html>
